package com.jymj.service.impl;

import com.jymj.dao.ApplyChildDao;
import com.jymj.entity.zjd.ApplyChildEntity;
import com.jymj.service.ApplyChildService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by ljj on 2018/9/17.
 */
@Service
public class ApplyChildServiceImpl implements ApplyChildService {
    @Autowired
    private ApplyChildDao applyChildDao;

    @Override
    public ApplyChildEntity queryObject(Integer applyId) {
        return applyChildDao.queryObject(applyId);
    }

    @Override
    public void save(ApplyChildEntity applyChildEntity) {
        applyChildDao.save(applyChildEntity);
    }

    @Override
    public void update(ApplyChildEntity applyChildEntity) {
        applyChildDao.update(applyChildEntity);
    }

    @Override
    public boolean next(Integer appChildId, Integer sgtype) {
        Map map = new HashMap();
        map.put("appChildId",appChildId);
        map.put("sgtype",sgtype);
        Integer count = applyChildDao.next(map);
        if(sgtype==71){
            if(count>=1){
                return true;
            }
            return false;
        }else if(sgtype==72){
            if(count>=2){
                return true;
            }
            return false;
        }else if(sgtype==73){
            if(count>=8){
                return true;
            }
            return false;
        }else {
            if(count>=11){
                return true;
            }
            return false;
        }
    }

    @Override
    public ApplyChildEntity queryByChid(Integer appChildId) {
        return applyChildDao.queryByChid(appChildId);
    }
}
